﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SmartRS.com.vn.smartrs.domain.custom
{
    public class BillDataTable
    {
        public long foodOrderId { get; set; }
        public string foodName { get; set; }
        public string foodUnit { get; set; }
        public string quantityOrder { get; set; }
        public long priceOrder { get; set; }
        public long discountValue { get; set; }
        public long priceCharge { get; set; }

        public IList<BillDataTable> copyProperties(Bill bill)
        {
            return copyProperties(bill.foodOrderList);
        }

        public IList<BillDataTable> copyProperties(IList<FoodOrder> foodOrderList)
        {
            IList<BillDataTable> billDataList = new List<BillDataTable>();
            //list is null or empty
            if (foodOrderList == null || foodOrderList.Count == 0)
            {
                return billDataList;
            }

            foreach (FoodOrder foodOrder in foodOrderList)
            {
                //Convert object
                var billDataTable =  copyProperties(foodOrder);
                //add element to list
                billDataList.Add(billDataTable);
            }


            return billDataList;
        }

        public BillDataTable copyProperties(FoodOrder foodOrder)
        {

            //FoodOrder is null or empty
            if (foodOrder == null)
            {
                return new BillDataTable();;
            }

            //Convert object
            BillDataTable billDataTable = new BillDataTable()
            {
                foodOrderId =  foodOrder.foodOrderId,
                foodName = foodOrder.food.foodName,
                foodUnit = foodOrder.food.foodUnit.foodUnitName,
                quantityOrder = foodOrder.quantityOrder.ToString(),
                priceOrder = foodOrder.priceWhenOrder,
                discountValue = foodOrder.discountValue,
                priceCharge = foodOrder.quantityOrder * foodOrder.priceWhenOrder
            };

            return billDataTable;
        }
    }
}
